<!--
 * @Author: wangkg wangkegui@longfor.com
 * @Date: 2024-08-06 10:35:54
 * @Description: 
-->
<template>
  <svg :class="[prefixCls, $attrs.class, spin && 'svg-icon-spin']" aria-hidden="true">
    <use :xlink:href="symbolId" />
  </svg>
</template>
<script lang="ts" setup>
import { computed } from 'vue';
import { getGlobalCls } from '@/utils/index';

defineOptions({ name: 'LcSvgIcon' });

const props = defineProps({
  prefix: {
    type: String,
    default: 'lc'
  },
  iconClass: {
    type: String,
    required: true
  },
  spin: {
    type: Boolean,
    default: false
  }
});

const { prefixCls } = getGlobalCls('svg-icon');
const prefix = props.prefix;
const symbolId = computed(() => `#${prefix ? prefix + '_' : ''}${props.iconClass}`);
</script>
<style lang="scss">
$prefix-cls: #{config.$namespace}-svg-icon;

.#{$prefix-cls} {
  display: inline-block;
  overflow: hidden;
  fill: currentcolor;
  vertical-align: -0.15em;
  font-size: 14px;
  width: 1em;
  height: 1em;
  &.svg-icon-spin {
    animation: loadingCircle 1s infinite linear;
  }
}
</style>
